package com.xabg.template.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xabg.template.entity.User;
import com.xabg.template.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xabg
 * @since 2018-09-17
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    IUserService iUserService;

    @GetMapping("/list")
    public List<User>  getAll(){
       List<User> users = iUserService.list(new QueryWrapper<>());
       return users;
    }

    @PostMapping("/age")
    public List<User> findByAge(int age){
        List<User> userList = iUserService.findByAge(age);
        return  userList;

    }
}
